---
hide_table_of_contents: true
sidebar_class_name: hidden
---

import CodeBlock from "@theme/CodeBlock";
import Example from "@examples/chat/memory.ts";

# Using Buffer Memory with Chat Models

This example covers how to use chat-specific memory classes with chat models.
The key thing to notice is that setting `returnMessages: true` makes the memory return a list of chat messages instead of a string.

import IntegrationInstallTooltip from "@mdx_components/integration_install_tooltip.mdx";

<IntegrationInstallTooltip></IntegrationInstallTooltip>

```bash npm2yarn
npm install @langchain/openai
```

<CodeBlock language="typescript">{Example}</CodeBlock>
